<?PHP




$data=$HTTP_RAW_POST_DATA;

eregi("<signature>(.*)<\/signature>", $data, $signatureT);

$signature=base64_decode($signatureT[1]);


$data=str_replace($signatureT[0],"",$data);




$fp = fopen("vposPHP.cer", "r"); 
$cert = fread($fp, 8192); 
fclose($fp); 
$pubkeyid = openssl_get_publickey($cert); 


$ok = openssl_verify($data, $signature, $pubkeyid); 

$file = fopen("test.txt","w");
/////////////////////////////////////////////////////////////////////////////////////////////
$data_2=$HTTP_RAW_POST_DATA;

eregi("<version>(.*)<\/version>", $data_2, $version_2);
eregi("<txnType>(.*)<\/txnType>", $data_2, $txnType_2);
eregi("<merchantId>(.*)<\/merchantId>", $data_2, $merchantId_2);
eregi("<terminalId>(.*)<\/terminalId>", $data_2, $terminalId_2);
eregi("<refNumber>(.*)<\/refNumber>", $data_2, $refNumber_2);

$export='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><MasMessage xmlns="http://www.99bill.com/mas_cnp_merchant_interface"><version>'.$version_2[1].'</version><TxnMsgContent><txnType>'.$txnType_2[1].'</txnType><interactiveStatus>TR3</interactiveStatus><merchantId>'.$merchantId_2[1].'</merchantId><terminalId>'.$terminalId_2[1].'</terminalId><refNumber>'.$refNumber_2[1].'</refNumber></TxnMsgContent></MasMessage>';

////////////////////////////////////////////////////////////////
if ($ok == 1) { 

fwrite($file,$export);
echo $export;
} elseif ($ok == 0) {
	
fwrite($file,'no');

} else { 

fwrite($file,'never');

} 
?>